package com.gjr.demo.EasyExcel.entity;

import com.alibaba.excel.EasyExcel;

import java.util.*;

/**
 * 使用 EasyExcel 导出excel
 */
public class exportExcelDemo {

    public static void main(String[] args) {
        // 输出地址
        String fileName = "C:\\Users\\lenovo\\Desktop\\write.xlsx";
        // 这里需要设置不关闭流
        /* EasyExcel.write(fileName, DemoData.class).sheet("模板").doWrite(data());*/

        EasyExcel.read(fileName, DemoData.class, new ExcelListener()).sheet().doRead();
    }

    private static List<DemoData> data() {
        List<DemoData> list = new ArrayList();
        for (int i = 0; i < 10; i++) {
            DemoData data = new DemoData();
            data.setString("字符串" + i);
            data.setDate(new Date());
            data.setDoubleData(0.56);
            list.add(data);
        }
        return list;
    }
}
